package com.example.computertms.mapper;

import com.example.computertms.pojo.ComputerType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ComputerTypeMapper {

    @Insert("insert into computerType (computerId, name, brand, type, prices, mainBoard, graphicsCard, hardDisk, internalStorage, cpu, merchant, imgSrc) " +
            "VALUE (#{computerId},#{name},#{brand},#{type},#{prices},#{mainBoard},#{graphicsCard},#{hardDisk},#{internalStorage},#{cpu},#{merchant},#{imgSrc})")
    void addComputerType(@Param("computerId")String computerId,@Param("name")String name,
                                 @Param("brand")String brand,@Param("type")String type,@Param("prices")String prices,@Param("mainBoard")String mainBoard,
                                 @Param("graphicsCard")String graphicsCard,@Param("hardDisk")String hardDisk,@Param("internalStorage")String internalStorage,
                                 @Param("cpu")String cpu,@Param("merchant")String merchant,@Param("imgSrc")String imgSrc);

    @Select("select * from computerType where computerId=#{computerId}")
    List<ComputerType> foundByComputerId(@Param("computerId")String computerId);

    @Select("select * from computerType where name like #{name}")
    List<ComputerType> foundByName(@Param("name")String name);

    @Update("update computerType set computerId=#{computerId},name=#{name},brand=#{brand},type=#{type},prices=#{prices},mainBoard=#{mainBoard}," +
            "graphicsCard=#{graphicsCard},hardDisk=#{hardDisk},internalStorage=#{internalStorage},cpu=#{cpu},merchant=#{merchant},imgSrc=#{imgSrc} " +
            "where computerId=#{computerId}")
    void changeComputerTypeByComputerId(@Param("computerId")String computerId,@Param("name")String name,
                            @Param("brand")String brand,@Param("type")String type,@Param("prices")String prices,@Param("mainBoard")String mainBoard,
                            @Param("graphicsCard")String graphicsCard,@Param("hardDisk")String hardDisk,@Param("internalStorage")String internalStorage,
                            @Param("cpu")String cpu,@Param("merchant")String merchant,@Param("imgSrc")String imgSrc);

    @Delete("delete from computerType where computerId=#{computerId}")
    void deleteComputerTypeByComputerId(@Param("computerId")String computerId);

    @Select("select * from computerType")
    List<ComputerType> foundAll();


}
